
 <!DOCTYPE HTML>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  
    <title>Android Studio调试Android Framework源码 | RyanHuen</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    
    <meta name="author" content="RyanHuen">
    

    
    <meta name="description" content="源码需要先编译一次
编译环境配置cd &amp;lt;phoenix_root&amp;gt;
source build/envsetup.sh
lunch aosp_flounder-userdebug（flounder:Nexus 9 flo Nexus 7二代 grouper Nexus 7一代）

编译
使用以下命令编译make -j16(-j16 CPU核数)

生成android.ipr和andro">
<meta property="og:type" content="article">
<meta property="og:title" content="Android Studio调试Android Framework源码">
<meta property="og:url" content="http://www.ryanhuen.tech/2017/02/12/studio_debug_source/index.html">
<meta property="og:site_name" content="RyanHuen">
<meta property="og:description" content="源码需要先编译一次
编译环境配置cd &amp;lt;phoenix_root&amp;gt;
source build/envsetup.sh
lunch aosp_flounder-userdebug（flounder:Nexus 9 flo Nexus 7二代 grouper Nexus 7一代）

编译
使用以下命令编译make -j16(-j16 CPU核数)

生成android.ipr和andro">
<meta property="og:updated_time" content="2017-02-15T11:48:55.725Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Android Studio调试Android Framework源码">
<meta name="twitter:description" content="源码需要先编译一次
编译环境配置cd &amp;lt;phoenix_root&amp;gt;
source build/envsetup.sh
lunch aosp_flounder-userdebug（flounder:Nexus 9 flo Nexus 7二代 grouper Nexus 7一代）

编译
使用以下命令编译make -j16(-j16 CPU核数)

生成android.ipr和andro">

    
    <link rel="alternative" href="/atom.xml" title="RyanHuen" type="application/atom+xml">
    
    
    <link rel="icon" href="/img/favicon.ico">
    
    
    <link rel="apple-touch-icon" href="/img/jacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/img/jacman.jpg">
    
    <link rel="stylesheet" href="/css/style.css">
</head>

  <body>
    <header>
      
<div>
		
			<div id="imglogo">
				<a href="/"><img src="/img/logo.png" alt="RyanHuen" title="RyanHuen"/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/" title="RyanHuen">RyanHuen</a></h1>
				<h2 class="blog-motto">I hope I can protect the one thing I can&#39;t live without.</h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="菜单">
			</a></div>
			<nav class="animated">
				<ul>
					<ul>
					 
						<li><a href="/">首页</a></li>
					
						<li><a href="/archives">历程</a></li>
					
						<li><a href="/categories">分类</a></li>
					
						<li><a href="/tags">标签</a></li>
					
						<li><a href="/about">关于</a></li>
					
					<li>
 					
					<form class="search" action="//google.com/search" method="get" accept-charset="utf-8">
						<label>Search</label>
						<input type="search" id="search" name="q" autocomplete="off" maxlength="20" placeholder="搜索" />
						<input type="hidden" name="q" value="site:www.ryanhuen.tech">
					</form>
					
					</li>
				</ul>
			</nav>			
</div>
    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
  
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2017/02/12/studio_debug_source/" title="Android Studio调试Android Framework源码" itemprop="url">Android Studio调试Android Framework源码</a>
  </h1>
  <p class="article-author">By
       
		<a href="/about" title="RyanHuen" target="_blank" itemprop="author">RyanHuen</a>
		
  <p class="article-time">
    <time datetime="2017-02-12T13:09:12.000Z" itemprop="datePublished"> 发表于 2017-02-12</time>
    
  </p>
</header>
	<div class="article-content">
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">文章目录</strong>
		
			<ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#源码需要先编译一次"><span class="toc-number">1.</span> <span class="toc-text">源码需要先编译一次</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#编译环境配置"><span class="toc-number">1.1.</span> <span class="toc-text">编译环境配置</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#编译"><span class="toc-number">1.2.</span> <span class="toc-text">编译</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#使用以下命令编译"><span class="toc-number">1.2.1.</span> <span class="toc-text">使用以下命令编译</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#生成android-ipr和android-iml文件"><span class="toc-number">2.</span> <span class="toc-text">生成android.ipr和android.iml文件</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#使用Studio调试源码"><span class="toc-number">3.</span> <span class="toc-text">使用Studio调试源码</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#索引源码"><span class="toc-number">3.1.</span> <span class="toc-text">索引源码</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#过滤源码"><span class="toc-number">3.2.</span> <span class="toc-text">过滤源码</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#过滤不需要的目录，加快索引速度："><span class="toc-number">3.2.1.</span> <span class="toc-text">过滤不需要的目录，加快索引速度：</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#修改android-iml文件"><span class="toc-number">3.3.</span> <span class="toc-text">修改android.iml文件</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#我们需要修改android-iml文件。"><span class="toc-number">3.3.1.</span> <span class="toc-text">我们需要修改android.iml文件。</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#关于-lt-sourceFolder-gt-标签"><span class="toc-number">3.3.2.</span> <span class="toc-text">关于<sourceFolder>标签</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#关于-lt-excludeFolder-gt-标签"><span class="toc-number">3.3.3.</span> <span class="toc-text">关于<excludeFolder>标签</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#关于-lt-orderEntry-gt-标签"><span class="toc-number">3.3.4.</span> <span class="toc-text">关于<orderEntry>标签</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#下面是修改的代码模板-大家可以参照一下"><span class="toc-number">4.</span> <span class="toc-text">下面是修改的代码模板,大家可以参照一下</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#注意事项："><span class="toc-number">5.</span> <span class="toc-text">注意事项：</span></a></li></ol>
		
		</div>
		
		<p><a id="org4fa9c49"></a></p>
<h1 id="源码需要先编译一次"><a href="#源码需要先编译一次" class="headerlink" title="源码需要先编译一次"></a>源码需要先编译一次</h1><p><a id="org2746a08"></a></p>
<h2 id="编译环境配置"><a href="#编译环境配置" class="headerlink" title="编译环境配置"></a>编译环境配置</h2><pre><code>cd &lt;phoenix_root&gt;
source build/envsetup.sh
lunch aosp_flounder-userdebug（flounder:Nexus 9 flo Nexus 7二代 grouper Nexus 7一代）
</code></pre><p><a id="orgd73cc9a"></a></p>
<h2 id="编译"><a href="#编译" class="headerlink" title="编译"></a>编译</h2><p><a id="org04394e2"></a></p>
<h3 id="使用以下命令编译"><a href="#使用以下命令编译" class="headerlink" title="使用以下命令编译"></a>使用以下命令编译</h3><pre><code>make -j16(-j16 CPU核数)
</code></pre><p><a id="org287d687"></a></p>
<h1 id="生成android-ipr和android-iml文件"><a href="#生成android-ipr和android-iml文件" class="headerlink" title="生成android.ipr和android.iml文件"></a>生成android.ipr和android.iml文件</h1><ol>
<li><p>进入源码根目录</p>
<ol>
<li><p>执行：</p>
<ol>
<li><p>这行命令的意思是编译idegen这个项目,生成idegen.jar文件.生成成功后,会显示这个jar包的位置,并显示 #### make completed successfully</p>
<pre><code>mmm development/tools/idegen/
</code></pre></li>
</ol>
</li>
<li><p>执行：</p>
<ol>
<li><p>这行命令的意思是生成对应的文件:android.iws, android.ipr, android.iml</p>
<pre><code>sh ./development/tools/idegen/idegen.sh
</code></pre></li>
</ol>
</li>
</ol>
</li>
</ol>
<p><a id="org63a79c7"></a></p>
<h1 id="使用Studio调试源码"><a href="#使用Studio调试源码" class="headerlink" title="使用Studio调试源码"></a>使用Studio调试源码</h1><p><a id="org353535a"></a></p>
<h2 id="索引源码"><a href="#索引源码" class="headerlink" title="索引源码"></a>索引源码</h2><ol>
<li>File&#x2013;》Open&#x2013;》找到源码目录，打开android.ipr文件，Studio就会开始索引源码</li>
</ol>
<p><a id="org49651df"></a></p>
<h2 id="过滤源码"><a href="#过滤源码" class="headerlink" title="过滤源码"></a>过滤源码</h2><p><a id="orgb5d0eb0"></a></p>
<h3 id="过滤不需要的目录，加快索引速度："><a href="#过滤不需要的目录，加快索引速度：" class="headerlink" title="过滤不需要的目录，加快索引速度："></a>过滤不需要的目录，加快索引速度：</h3><ol>
<li><p>修改android.iml文件，可以去除或者添加需要Studio进行索引的目录</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/.repo"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/abi"</span> /&gt;</span></div></pre></td></tr></table></figure>
</li>
<li><p>上述代码标签表示我们指定某个目录不需要需要被Studio进行索引。索引后的目录中的java文件都会被Studio包含进来。</p>
<ol>
<li><p>索引时间比较长，大家着急的话，可以让Studio先索引着，继续往下看</p>
</li>
<li><p>到达这一步，源码可以看了，但是还不能调试</p>
</li>
</ol>
</li>
</ol>
<p><a id="orgc28b660"></a></p>
<h2 id="修改android-iml文件"><a href="#修改android-iml文件" class="headerlink" title="修改android.iml文件"></a>修改android.iml文件</h2><ol>
<li>细心的读者可能会发现Attach debugger to Android process按钮还不能启用。也就是目前还不能attach进程调试</li>
</ol>
<p><a id="org7f59113"></a></p>
<h3 id="我们需要修改android-iml文件。"><a href="#我们需要修改android-iml文件。" class="headerlink" title="我们需要修改android.iml文件。"></a>我们需要修改android.iml文件。</h3><ol>
<li>确保android.iml文件是如下代码开头，如果不是，需要修改成下面状态<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</div><div class="line"><span class="tag">&lt;<span class="name">module</span> <span class="attr">relativePaths</span>=<span class="string">"true"</span> <span class="attr">type</span>=<span class="string">"JAVA_MODULE"</span> <span class="attr">version</span>=<span class="string">"4"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">component</span> <span class="attr">name</span>=<span class="string">"FacetManager"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">facet</span> <span class="attr">type</span>=<span class="string">"android"</span> <span class="attr">name</span>=<span class="string">"Android"</span>&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">configuration</span> /&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">facet</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">component</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">component</span> <span class="attr">name</span>=<span class="string">"NewModuleRootManager"</span> <span class="attr">inherit-compiler-output</span>=<span class="string">"true"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">exclude-output</span> /&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">content</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$"</span>&gt;</span></div><div class="line"> <span class="comment">&lt;!--到这里往下就是&lt;sourceFolder&gt;标签的内容了--&gt;</span></div></pre></td></tr></table></figure>
</li>
</ol>
<p><a id="org902fc64"></a></p>
<h3 id="关于-lt-sourceFolder-gt-标签"><a href="#关于-lt-sourceFolder-gt-标签" class="headerlink" title="关于&lt;sourceFolder&gt;标签"></a>关于&lt;sourceFolder&gt;标签</h3><ol>
<li>去除不需要debug的&lt;sourceFolder/&gt;标签内容,通常我们只需要frameworks和packages两个目录，所以保留这两个目录有关的标签就行，其他全部删掉，这样索引的速度就会加快了。</li>
</ol>
<p><a id="orge3e6898"></a></p>
<h3 id="关于-lt-excludeFolder-gt-标签"><a href="#关于-lt-excludeFolder-gt-标签" class="headerlink" title="关于&lt;excludeFolder&gt;标签"></a>关于&lt;excludeFolder&gt;标签</h3><ol>
<li><p>exclude顾名思义就是不包含的意思。我们有很多目录直接就不想让Studio去管它，不管是索引还是什么等等，所以只需要将这些目录配置到&lt;excludeFolder&gt;中就好了。</p>
</li>
<li><p>如下：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/.repo"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/abi"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/art"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/bionic"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/bootable"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/build"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/cts"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/dalvik"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/developers"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/development"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/device"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/docs"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external/bluetooth"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external/chromium"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external/emma"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external/icu4c"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external/jdiff"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external/webkit"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/frameworks/base/docs"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/frameworks/base/tests"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/frameworks/base/tools"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/hardware"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/libcore"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/libnativehelper"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/ndk"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/out"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/pdk"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/platform_testing"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/prebuilt"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/sdk"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/tools"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/vendor"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/toolchain"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/system"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/prebuilts"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/phoenix"</span> /&gt;</span></div></pre></td></tr></table></figure>
</li>
</ol>
<p><a id="org88f6c13"></a></p>
<h3 id="关于-lt-orderEntry-gt-标签"><a href="#关于-lt-orderEntry-gt-标签" class="headerlink" title="关于&lt;orderEntry&gt;标签"></a>关于&lt;orderEntry&gt;标签</h3><ol>
<li><p>删除所有&lt;orderEntry /&gt;标签</p>
</li>
<li><p>删除以后添加以下两个：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">orderEntry</span> <span class="attr">type</span>=<span class="string">"sourceFolder"</span> <span class="attr">forTests</span>=<span class="string">"false"</span> /&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">orderEntry</span> <span class="attr">type</span>=<span class="string">"jdk"</span> <span class="attr">jdkName</span>=<span class="string">"Android API 22 Platform"</span> <span class="attr">jdkType</span>=<span class="string">"Android SDK"</span> /&gt;</span></div></pre></td></tr></table></figure>
</li>
</ol>
<p><a id="org3139177"></a></p>
<h1 id="下面是修改的代码模板-大家可以参照一下"><a href="#下面是修改的代码模板-大家可以参照一下" class="headerlink" title="下面是修改的代码模板,大家可以参照一下"></a>下面是修改的代码模板,大家可以参照一下</h1><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</div><div class="line"><span class="tag">&lt;<span class="name">module</span> <span class="attr">relativePaths</span>=<span class="string">"true"</span> <span class="attr">type</span>=<span class="string">"JAVA_MODULE"</span> <span class="attr">version</span>=<span class="string">"4"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">component</span> <span class="attr">name</span>=<span class="string">"FacetManager"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">facet</span> <span class="attr">type</span>=<span class="string">"android"</span> <span class="attr">name</span>=<span class="string">"Android"</span>&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">configuration</span> /&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">facet</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">component</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">component</span> <span class="attr">name</span>=<span class="string">"NewModuleRootManager"</span> <span class="attr">inherit-compiler-output</span>=<span class="string">"true"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">exclude-output</span> /&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">content</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$"</span>&gt;</span></div><div class="line">      <span class="comment">&lt;!--sourceFolder标签表示需要索引的代码目录--&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">sourceFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/frameworks/base/core/java"</span> <span class="attr">isTestSource</span>=<span class="string">"false"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">sourceFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/gen"</span> <span class="attr">isTestSource</span>=<span class="string">"false"</span> <span class="attr">generated</span>=<span class="string">"true"</span> /&gt;</span></div><div class="line">      <span class="comment">&lt;!--excludeFolder标签表示这个目录下所有内容都不索引--&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/.repo"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/abi"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/art"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/bionic"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/bootable"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/build"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/cts"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/dalvik"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/developers"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/development"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/device"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/docs"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external/bluetooth"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external/chromium"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external/emma"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external/icu4c"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external/jdiff"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/external/webkit"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/frameworks/base/docs"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/frameworks/base/tests"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/frameworks/base/tools"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/hardware"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/libcore"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/libnativehelper"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/ndk"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/out"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/pdk"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/platform_testing"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/prebuilt"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/sdk"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/tools"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/vendor"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/toolchain"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/system"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/prebuilts"</span> /&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">excludeFolder</span> <span class="attr">url</span>=<span class="string">"file://$MODULE_DIR$/phoenix"</span> /&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">content</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">orderEntry</span> <span class="attr">type</span>=<span class="string">"sourceFolder"</span> <span class="attr">forTests</span>=<span class="string">"false"</span> /&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">orderEntry</span> <span class="attr">type</span>=<span class="string">"jdk"</span> <span class="attr">jdkName</span>=<span class="string">"Android API 22 Platform"</span> <span class="attr">jdkType</span>=<span class="string">"Android SDK"</span> /&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">component</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">module</span>&gt;</span></div></pre></td></tr></table></figure>
<p><a id="org8f3d051"></a></p>
<h1 id="注意事项："><a href="#注意事项：" class="headerlink" title="注意事项："></a>注意事项：</h1><ol>
<li>如果想要在IDE中修改源码，需要关闭Android Studio的auto import功能，否则IDE会自动导入一些东西，会引起编译错误。原因未明。知道原因的小伙伴，麻烦不吝赐教啦。</li>
</ol>
  
	</div>
		<footer class="article-footer clearfix">
<div class="article-catetags">

<div class="article-categories">
  <span></span>
  <a class="article-category-link" href="/categories/Framework系列/">Framework系列</a>
</div>


  <div class="article-tags">
  
  <span></span> <a href="/tags/Android-Studio/">Android Studio</a><a href="/tags/Framework/">Framework</a><a href="/tags/Debug/">Debug</a>
  </div>

</div>



	<div class="article-share" id="share">
	
	  <div data-url="http://www.ryanhuen.tech/2017/02/12/studio_debug_source/" data-title="Android Studio调试Android Framework源码 | RyanHuen" data-tsina="null" class="share clearfix">
	  </div>
	
	</div>


</footer>

   	       
	</article>
	
<nav class="article-nav clearfix">
 
 <div class="prev" >
 <a href="/2017/02/14/JavaCallBack/" title="JavaCallBack">
  <strong>上一篇：</strong><br/>
  <span>
  JavaCallBack</span>
</a>
</div>


<div class="next">
<a href="/2017/02/10/git_patch/"  title="git补丁管理">
 <strong>下一篇：</strong><br/> 
 <span>git补丁管理
</span>
</a>
</div>

</nav>

	
<section id="comments" class="comment">
	<div class="ds-thread" data-thread-key="2017/02/12/studio_debug_source/" data-title="Android Studio调试Android Framework源码" data-url="http://www.ryanhuen.tech/2017/02/12/studio_debug_source/"></div>
</section>


</div>  
      <div class="openaside"><a class="navbutton" href="#" title="显示侧边栏"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">文章目录</strong>
 
 <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#源码需要先编译一次"><span class="toc-number">1.</span> <span class="toc-text">源码需要先编译一次</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#编译环境配置"><span class="toc-number">1.1.</span> <span class="toc-text">编译环境配置</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#编译"><span class="toc-number">1.2.</span> <span class="toc-text">编译</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#使用以下命令编译"><span class="toc-number">1.2.1.</span> <span class="toc-text">使用以下命令编译</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#生成android-ipr和android-iml文件"><span class="toc-number">2.</span> <span class="toc-text">生成android.ipr和android.iml文件</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#使用Studio调试源码"><span class="toc-number">3.</span> <span class="toc-text">使用Studio调试源码</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#索引源码"><span class="toc-number">3.1.</span> <span class="toc-text">索引源码</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#过滤源码"><span class="toc-number">3.2.</span> <span class="toc-text">过滤源码</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#过滤不需要的目录，加快索引速度："><span class="toc-number">3.2.1.</span> <span class="toc-text">过滤不需要的目录，加快索引速度：</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#修改android-iml文件"><span class="toc-number">3.3.</span> <span class="toc-text">修改android.iml文件</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#我们需要修改android-iml文件。"><span class="toc-number">3.3.1.</span> <span class="toc-text">我们需要修改android.iml文件。</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#关于-lt-sourceFolder-gt-标签"><span class="toc-number">3.3.2.</span> <span class="toc-text">关于<sourceFolder>标签</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#关于-lt-excludeFolder-gt-标签"><span class="toc-number">3.3.3.</span> <span class="toc-text">关于<excludeFolder>标签</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#关于-lt-orderEntry-gt-标签"><span class="toc-number">3.3.4.</span> <span class="toc-text">关于<orderEntry>标签</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#下面是修改的代码模板-大家可以参照一下"><span class="toc-number">4.</span> <span class="toc-text">下面是修改的代码模板,大家可以参照一下</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#注意事项："><span class="toc-number">5.</span> <span class="toc-text">注意事项：</span></a></li></ol>
 
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="隐藏侧边栏"></a></div>
<aside class="clearfix">

  
<div class="categorieslist">
	<p class="asidetitle">分类</p>
		<ul>
		
		  
			<li><a href="/categories/Emacs系列/" title="Emacs系列">Emacs系列<sup>3</sup></a></li>
		  
		
		  
			<li><a href="/categories/Framework系列/" title="Framework系列">Framework系列<sup>1</sup></a></li>
		  
		
		  
			<li><a href="/categories/RXJava系列/" title="RXJava系列">RXJava系列<sup>7</sup></a></li>
		  
		
		  
			<li><a href="/categories/git入门系列/" title="git入门系列">git入门系列<sup>5</sup></a></li>
		  
		
		  
			<li><a href="/categories/Emacs系列/org-mode/" title="org-mode">org-mode<sup>1</sup></a></li>
		  
		
		</ul>
</div>


  
<div class="tagslist">
	<p class="asidetitle">标签</p>
		<ul class="clearfix">
		
			
				<li><a href="/tags/RxJava/" title="RxJava">RxJava<sup>7</sup></a></li>
			
		
			
				<li><a href="/tags/git/" title="git">git<sup>5</sup></a></li>
			
		
			
				<li><a href="/tags/RxJava基础/" title="RxJava基础">RxJava基础<sup>4</sup></a></li>
			
		
			
				<li><a href="/tags/Spacemacs/" title="Spacemacs">Spacemacs<sup>3</sup></a></li>
			
		
			
				<li><a href="/tags/Emacs/" title="Emacs">Emacs<sup>3</sup></a></li>
			
		
			
				<li><a href="/tags/观察者模式/" title="观察者模式">观察者模式<sup>3</sup></a></li>
			
		
			
				<li><a href="/tags/BackPressure/" title="BackPressure">BackPressure<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/org/" title="org">org<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/Java回调/" title="Java回调">Java回调<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/Debug/" title="Debug">Debug<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/设计模式/" title="设计模式">设计模式<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/RxJava操作符/" title="RxJava操作符">RxJava操作符<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/响应式编程/" title="响应式编程">响应式编程<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/Android-Studio/" title="Android Studio">Android Studio<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/Framework/" title="Framework">Framework<sup>1</sup></a></li>
			
		
			
				<li><a href="/tags/org-mode/" title="org-mode">org-mode<sup>1</sup></a></li>
			
		
		</ul>
</div>


  <div class="rsspart">
	<a href="/atom.xml" target="_blank" title="rss">RSS 订阅</a>
</div>

</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<div class="line">
		<span></span>
		<div class="author"></div>
	</div>
	
	
	<section class="info">
		<p> Hi there,I&#39;m RyanHuen <br/>
			A simple programmer</p>
	</section>
	 
	<div class="social-font" class="clearfix">
		
		<a href="http://weibo.com/ryanxuan" target="_blank" class="icon-weibo" title="微博"></a>
		
		
		<a href="https://github.com/RyanHuen" target="_blank" class="icon-github" title="github"></a>
		
		
		
		
		
		
		
		<a href="http://www.zhihu.com/people/ryan-hyn" target="_blank" class="icon-zhihu" title="知乎"></a>
		
		
		
		<a href="mailto:ryanhuenwork@163.com" target="_blank" class="icon-email" title="Email Me"></a>
		
	</div>
			
		

		<p class="copyright">
		Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/wuchong/jacman" target="_blank" title="Jacman">Jacman</a> © 2017 
		
		<a href="/about" target="_blank" title="RyanHuen">RyanHuen</a>
		
		
		</p>
</div>
</footer>
    <script src="/js/jquery-2.0.3.min.js"></script>
<script src="/js/jquery.imagesloaded.min.js"></script>
<script src="/js/gallery.js"></script>
<script src="/js/jquery.qrcode-0.12.0.min.js"></script>

<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
  
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else{
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  c.click(function(){
    ta.css('display', 'block').addClass('fadeIn');
  });
  o.click(function(){
    ta.css('display', 'none');
  });
  $(window).scroll(function(){
    ta.css("top",Math.max(140,320-$(this).scrollTop()));
  });
});
</script>


<script type="text/javascript">
$(document).ready(function(){ 
  var $this = $('.share'),
      url = $this.attr('data-url'),
      encodedUrl = encodeURIComponent(url),
      title = $this.attr('data-title'),
      tsina = $this.attr('data-tsina'),
      description = $this.attr('description');
  var html = [
  '<div class="hoverqrcode clearfix"></div>',
  '<a class="overlay" id="qrcode"></a>',
  '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="article-share-facebook" target="_blank" title="Facebook"></a>',
  '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="article-share-twitter" target="_blank" title="Twitter"></a>',
  '<a href="#qrcode" class="article-share-qrcode" title="微信"></a>',
  '<a href="http://widget.renren.com/dialog/share?resourceUrl=' + encodedUrl + '&srcUrl=' + encodedUrl + '&title=' + title +'" class="article-share-renren" target="_blank" title="人人"></a>',
  '<a href="http://service.weibo.com/share/share.php?title='+title+'&url='+encodedUrl +'&ralateUid='+ tsina +'&searchPic=true&style=number' +'" class="article-share-weibo" target="_blank" title="微博"></a>',
  '<span title="Share to"></span>'
  ].join('');
  $this.append(html);

  $('.hoverqrcode').hide();

  var myWidth = 0;
  function updatehoverqrcode(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
    var qrsize = myWidth > 1024 ? 200:100;
    var options = {render: 'image', size: qrsize, fill: '#2ca6cb', text: url, radius: 0.5, quiet: 1};
    var p = $('.article-share-qrcode').position();
    $('.hoverqrcode').empty().css('width', qrsize).css('height', qrsize)
                          .css('left', p.left-qrsize/2+20).css('top', p.top-qrsize-10)
                          .qrcode(options);
  };
  $(window).resize(function(){
    $('.hoverqrcode').hide();
  });
  $('.article-share-qrcode').click(function(){
    updatehoverqrcode();
    $('.hoverqrcode').toggle();
  });
  $('.article-share-qrcode').hover(function(){}, function(){
      $('.hoverqrcode').hide();
  });
});   
</script>



<script type="text/javascript">
  var duoshuoQuery = {short_name:"ryanhuen"};
  (function() {
    var ds = document.createElement('script');
    ds.type = 'text/javascript';ds.async = true;
    ds.src = '//static.duoshuo.com/embed.js';
    ds.charset = 'UTF-8';
    (document.getElementsByTagName('head')[0] 
    || document.getElementsByTagName('body')[0]).appendChild(ds);
  })();
</script> 







<link rel="stylesheet" href="/fancybox/jquery.fancybox.css" media="screen" type="text/css">
<script src="/fancybox/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.article-content').each(function(i){
    $(this).find('img').each(function(){
      if ($(this).parent().hasClass('fancybox')) return;
      var alt = this.alt;
      if (alt) $(this).after('<span class="caption">' + alt + '</span>');
      $(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>');
    });
    $(this).find('.fancybox').each(function(){
      $(this).attr('rel', 'article' + i);
    });
  });
  if($.fancybox){
    $('.fancybox').fancybox();
  }
}); 
</script>



<!-- Analytics Begin -->



<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?af124d045b4aed59105f75db52359992";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>



<!-- Analytics End -->

<!-- Totop Begin -->

	<div id="totop">
	<a title="返回顶部"><img src="/img/scrollup.png"/></a>
	</div>
	<script src="/js/totop.js"></script>

<!-- Totop End -->

<!-- MathJax Begin -->
<!-- mathjax config similar to math.stackexchange -->


<!-- MathJax End -->

<!-- Tiny_search Begin -->

<!-- Tiny_search End -->

  </body>
</html>
